//配置路由相关的信息
import VueRouter from 'vue-router'
import vue from 'vue';

//导入
/* import Home from '../components/Home'
import About from '../components/About'
import User from '../components/User.vue'
 */

const Home=()=>import('../components/Home');
const HomeNews=()=>import('../components/HomeNews');
const HomeMessage=()=>import('../components/HomeMessage');


const About=()=>import('../components/About');
const User=()=>import('../components/User');



//1.通过Vue.use(插件),安装插件
vue.use(VueRouter);

//2.创建路由对象
const routes=[
	{
		path:'/',
		//redirect重定向
		redirect:'/home'
	},
	{
		path:'/home',
		component:Home,
		children:[
			//默认显示
			{
				path:'/',
				//redirect重定向
				redirect:'news'
			},
			{
				path:'news',
				component:HomeNews
			},
			{
			path:'message',
			component:HomeMessage
			}
		]
	},{
		path:'/about',
		component:About
	},{
		path:'/user/:userId',
		component:User
	}
]

const router =new VueRouter({
	//配置路由和组件之间的应用关系
	routes,
	//模式 html5的history模式
	mode:'history',
	//选中时class别名
	linkActiveClass:'active'
})

//3.将router对象传入到vue
export default router